import { Message } from 'element-ui'
import api from '../../http/api'
import router from '../../router/index'

export default {
    // 开启命名空间
    namespaced: true,
    state: {
        users: [],
        
    },
    mutations: {
        //用户列表
        setUsers(state, data) {
            state.users = data
        },
       
    },
    actions: {
        

        // 用户数据请求，commit解构而来
        async getUsers({ commit }, params) {
            let res = await api.getUsers(params)
            console.log(res)
            if (res.meta.status === 200) {
                // Message.success(res.meta.msg)
                commit('setUsers', res.data)
            } else {
                Message.error(res.meta.msg)
            }
        },

        

    },
}
